import {
  Controller,
  Get,
  Post,
} from '../decorator/router'

import Pug from 'pug'
import { videoTpl } from '../tpl'
import { getVideos } from '../service/videos'
import {resolve} from 'path'

@Controller('/videos')
export default class DocumentRouter {

  @Get('/:videoid')
  async getVideo (ctx, next) {
    console.log(ctx.params)
    const videoid = ctx.params.videoid
    let {
      video_list,
      video_src,
      prev_url,
      next_url,
      current_url
    } = await getVideos(videoid)

    let notes_placeholder = `1. 在此记录你的想法

2. 推荐使用Markdown语法
`
    let wenda_placeholder = `1. 描述你的问题

2. 贴上相关代码

3. 贴上报错信息

4. 推荐使用Markdown语法
`

    ctx.body = Pug.render(videoTpl, {
      video_list: video_list,
      video_src: video_src,
      prev_url: prev_url,
      next_url: next_url,
      current_url: current_url,
      course_url: '/learn/3001',
      course_title: '微信支付-扫码支付',
      notes_placeholder: notes_placeholder,
      wenda_placeholder: wenda_placeholder
    })
  }

}
